addpath([pwd,"/lib"]);
addpath([pwd,"/src"]);

load("rec.dat");
load("tstl.dat");

stats=[rec, tstl];

scores=[];
iterations = 10;
startTime = cputime;
confidenceLevel=0.44;

for(trial=1:iterations)
	[trainSet testSet]  = splitSet(stats, 0.5);
	
	credibilityMatrix	= getPerformanceMatrix(trainSet);
	[testAnswers confidence] = maxCredibilityAnswer(testSet(:,1:end-1), credibilityMatrix, 0.78);
	testAnswers(confidence<confidenceLevel)=10;
	scores=[scores; sum(testAnswers==testSet(:,6))/size(testSet,1), sum(testAnswers==10)/size(testSet,1)];
	printf("ITERATION: %d, TIME ELAPSED: %d sec \n",trial,cputime-startTime);
	printf("Last-> score	: %f, discarded: %f \n",scores(size(scores,1),1),scores(size(scores,1),2));
	printf("Mean-> score : %f, discarded: %f, errors: %f \n",mean(scores(:,1)), ...
		mean(scores(:,2)), 1-mean(scores(:,1))-mean(scores(:,2)));
	fflush(stdout);
	
end;

printf("Average over %d iterations -> score: %f, discarded: %f \n", iterations, mean(scores(:,1)), mean(scores(:,2)), ...
	1-mean(scores(:,1))-mean(scores(:,2)));

